package com.tedu.day04mybatis.mapper;

import com.tedu.day04mybatis.pojo.WeiBo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface WeiBoMapper {
    @Insert("INSERT INTO weibo (content,created,user_id) VALUES (#{content},#{created},#{userId})")
    int insert(WeiBo weiBo);

    @Delete("DELETE FROM weibo WHERE id=#{id}")
    int deleteById(Integer id);

    @Update("UPDATE weibo SET content = #{content},created = #{created},user_id =#{userId} WHERE id=#{id}")
    int updateWeibo(WeiBo weiBo);

    @Select("SELECT id,content,created,user_id userId FROM weibo WHERE id=#{id}")
    WeiBo findWeiboById(Integer id);

    @Select("SELECT id,content,created,user_id userId FROM weibo")
    List<WeiBo> find();


}
